feat(db): add monthly event partitions#363
Merged
Merged
Conversation
Event and activity tables need a partition-compatible target schema before Phase 4 can move beyond row-level archiving. Create PostgreSQL monthly partition parents and rolling partitions for publish, extension, project activity, and workspace activity events. Event tables now use created_at-aware primary keys, and extension callback deduplication stays serialized without relying on a global unique event id.
The partitioned event schema changes the primary key shape for append-only event and activity tables. Add schema assertions for the created_at-aware keys and mirror that shape in the SQLite service test fixture. Tests now catch regressions that would make the monthly partition DDL incompatible with the Go models.
The database optimization plan should reflect the completed monthly partitioning slice for event and activity tables. Mark the Phase 4 checklist item complete and add the new schema and test files as verification entry points. The roadmap now shows the remaining Phase 4 work around browser sessions, collaboration batches, cold export, and recovery.
Review found that monthly partitions could age out in long-lived processes and extension event deduplication was no longer a durable database invariant. Add default partitions for event tables and introduce an unpartitioned extension event claim table keyed by event id. Future-dated event inserts now have a partition fallback, and duplicate extension callbacks are blocked consistently across database backends.
Duplicate extension callbacks need idempotent claim handling on PostgreSQL without aborting the transaction. Schema sync now backfills extension event claims and drains default rows into real monthly partitions. Existing callbacks stay deduplicated and future partition maintenance preserves pruning.
Archived extension events leave durable callback claims behind after the event rows are removed. The archive delete phase now runs an optional hook and removes claims for archived extension event IDs in the same transaction. Old claims stop blocking reused event IDs while hot event claims remain intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
(id, created_at)primary keys so the schema is compatible withcreated_atrange partitioning.Implementation Approach
event_idunique constraint by serializing duplicate checks with a PostgreSQL advisory transaction lock.Testing
go test ./...frombackendpassed.bash script/ci/backend.shpassed.backend-formatandbackend-lintpassed for each commit.